<?php 

echo Utils::breadCrumbs(array(array('label' => 'My beverage list')));

$beverages = isset($_SESSION['selection']) ? $_SESSION['selection'] : array();
if ( empty($beverages) ):  ?>

<div style="margin:0 15px">
	<h2>Hi! You seem to be new in here</h2>
	<p>In order to add new beverages to your list, just <img src="img/icons/add.png" class="button_icon"/><a class="button" href="index.php?p=additem">click here</a></p>
</div>

<?php else: ?>

<p class="button_container" style="margin:0px 86px;">
	<img src="img/icons/remove.png" class="button_icon"/><a class="button red" href="index.php?p=deleteall" title="Clear all my beverages list">Clear my list!</a>
	<img src="img/icons/add.png" class="button_icon"/><a class="button green" href="index.php?p=additem" title="Add a new beverages">Add beverage</a>
</p>
<table id="my-selection">
	<caption>My Google CoffeMate&trade; selection list</caption>
	<thead>
		<tr>
			<th>Selections</th>
			<th>Details</th>
			<th>Actions</th>
		</tr>					
	</thead>
	<tbody>
		<?php 
			//var_dump($_SESSION['selection']); 
			krsort($beverages);
			foreach($beverages as $id=>$entry): 
				$entry['id'] = $id;
		?>
		<tr>
			<td>
				<a href="index.php?p=editselection&i=<?php echo $entry['id']; ?>" title="Edit this selection">
					<img src="<?php echo $entry['image_src']; ?>" alt="<?php echo $entry['image_alt']; ?>"/>
				</a>
			</td>
			<td>
				<p>
					<b>Name:</b> <?php echo $entry['name']; ?><br/>
					<b>Sugar:</b> <?php echo isset($entry['sugar']) ? $entry['sugar'] : 'No Sugar'; ?><br/>
					<b>Size:</b> <?php echo ucfirst($entry['size']); ?></li>
				</p>
			</td>
			<td class="action_container">
				<?php if ( !$entry['isDefault'] ): ?>
				<img src="img/icons/star.png" class="button_icon"/><a href="index.php?p=defaultselection&i=<?php echo $entry['id']; ?>" title="Set this selection to be my default one" class="button green">Make default</a>
				<?php endif; ?>
				<img src="img/icons/edit.png" class="button_icon"/><a href="index.php?p=editselection&i=<?php echo $entry['id']; ?>" title="Edit this selection" class="button blue">Edit</a>
				<img src="img/icons/remove.png" class="button_icon"/><a href="index.php?p=deleteselection&i=<?php echo $entry['id']; ?>" title="Delete this selection" class="button red">Delete</a>
			</td>
		</tr>
		<?php endforeach; ?>
	</tbody>	
</table>
<?php endif; ?>
